//
//  UILabel.swift
//  SinaWeibo
//
//  Created by 李亮亮 on 16/4/12.
//  Copyright © 2016年 Big Fish. All rights reserved.
//

import UIKit

extension UILabel {
    
    convenience init(text: String, textColor: UIColor, fontSize: CGFloat, margin: CGFloat = 0) {
        self.init()
        self.text = text
        self.textColor = textColor
        font = UIFont.systemFontOfSize(fontSize)
        numberOfLines = 0
        // 设置居中
        textAlignment = .Center
        if margin > 0 {
            // 设置最大显示的宽度
            preferredMaxLayoutWidth = ScreenWidth - 2 * margin
            textAlignment = .Left
        }
        // 自适应大小
        sizeToFit()
    }
}



